<?php

namespace Lib\Dao;
use Utils;
use Lib\Dao\FcfDao;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;

define('TABLA_LOGS','logs');
define('CAMPOS_TABLA_LOGS','id,tipo,texto,fecha,ip,navegador,id_usuario');

class LogsDao {
	
	
	static function nuevo($tipo,$texto){
		$debug = true;

		$texto = str_replace('\'','', $texto);
		$queryString = "INSERT INTO ".TABLA_LOGS." (".CAMPOS_TABLA_LOGS.")
						VALUES (null,
						        '".$tipo."',
						        '".$texto."',
						        CURRENT_TIMESTAMP,
						        '".$_SERVER['REMOTE_ADDR']."',
						        '".$_SERVER['HTTP_USER_AGENT']."',
							    ".Auth::user()->id.");";
		if($debug == true){
			return FcfDao::insertLog($queryString);
		}
	}



	static function getAllLogs(){
		$queryString = "Select ".CAMPOS_TABLA_LOGS." from ".TABLA_LOGS." ORDER BY fecha DESC";
		return FcfDao::select($queryString);
	}
	
	static function nuevoBug($texto){
		$queryString = "INSERT INTO bugs (id,usuario,texto,creado) VALUES (null,'".Auth::user()->id."','".$texto."',CURRENT_TIMESTAMP);";
		return FcfDao::insert($queryString);
	}
	
	static function getBugs(){
		$queryString = "Select * from bugs ORDER BY creado DESC";
		return FcfDao::select($queryString);
	}
	


}

?>